package view.ui 
{
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	
	/**
	 * ...
	 * @author ...
	 */
	public class HeadBar extends Sprite 
	{
		private var _logo:MovieClip;
		
		/**
		 * 绿色的底
		 */
		private var _bg:MovieClip;
		
		/**
		 * 顶部内容的容器
		 */
		private var _cont:Sprite;
		
		private var _nav:MainNav;
		
		public function HeadBar() 
		{
			addEventListener(Event.ADDED_TO_STAGE, onAddToStage);
		}
		
		private function onAddToStage(e:Event):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, onAddToStage);
			_bg = new SKheadBg();
			addChild(_bg);			
			
			_cont = new Sprite(); 
			addChild(_cont);
			
			_nav = new MainNav();
			_nav.x = 180;
			_cont.addChild(_nav);
			
			_logo = new SKlogo();
			_logo.x = 20;
			_logo.y = 7;
			_cont.addChild(_logo);
			
			onStageResize();
			stage.addEventListener(Event.RESIZE, onStageResize);
		}
		
		private function onStageResize(evt:Event = null):void
		{
			_bg.width = stage.stageWidth;		
			if (stage.stageWidth < 960) _cont.x = 0;
			else {
				_cont.x = stage.stageWidth - 0.5 * (stage.stageWidth  - 960) - 960;
			}			
		}
		
	}

}